#ifndef VISITOR_PATTERN_H
#define VISITOR_PATTERN_H

#include <vector>

using namespace std;

class ComputerPartVisitor;

class ComputerPart
{
public:
    virtual ~ComputerPart() {}

    virtual void accept(ComputerPartVisitor* computerPartVisitor) = 0;
};

class Keyboard : public ComputerPart
{
public:
    ~Keyboard() {}

    void accept(ComputerPartVisitor *computerPartVisitor) override;
};

class Monitor : public ComputerPart
{
public:
    ~Monitor() {}

    void accept(ComputerPartVisitor *computerPartVisitor) override;
};

class Mouse : public ComputerPart
{
public:
    ~Mouse() {}

    void accept(ComputerPartVisitor *computerPartVisitor) override;
};

class Computer
{
public:
    Computer();
    ~Computer();

    void accept(ComputerPartVisitor *computerPartVisitor);

private:
    vector<ComputerPart*> parts;
};

class ComputerPartVisitor
{
public:
    ~ComputerPartVisitor() {}

    virtual void visit(Computer* computer) = 0;
    virtual void visit(Mouse* mouse) = 0;
    virtual void visit(Keyboard* keyboard) = 0;
    virtual void visit(Monitor* monitor) = 0;
};

class ComputerPartDisplayVisitor : public ComputerPartVisitor
{
public:
    ~ComputerPartDisplayVisitor() {}

    void visit(Computer *computer) override;
    void visit(Mouse *mouse) override;
    void visit(Keyboard *keyboard) override;
    void visit(Monitor *monitor) override;
};

#endif // VISITOR_PATTERN_H
